package com.qf.sys.service.impl;

import com.qf.entity.sys.SysUser;
import com.qf.exception.CustomerException;
import com.qf.sys.dao.SysUserDAO;
import com.qf.sys.param.LoginParam;
import com.qf.sys.service.SysUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class SysUserServiceimpl implements SysUserService {
    @Resource
    private SysUserDAO sysUserDAO;


    @Override
    public SysUser login(LoginParam loginParam) {
        SysUser sysUser = sysUserDAO.selectByUserName(loginParam.getUsername());
        if (sysUser == null) {// 用户不存在
            throw new CustomerException("50001","用户不存在");
        }
        if (!(sysUser.getPassword().equals(loginParam.getPassword()))) {
            throw new CustomerException("50002","密码错误");
        }
        return sysUser;
    }
}
